package com.kly.cashmall.module.profile.adapter;

import android.text.TextUtils;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.kly.cashmall.R;
import com.kly.cashmall.bean.ProfileActionListBean;
import com.kly.cashmall.utils.function.GlideUtils;


/**
 * Created by
 * on 2019/4/28.
 */
public class ProfileListAdapter extends BaseQuickAdapter<ProfileActionListBean, BaseViewHolder> {

    public ProfileListAdapter() {
        super(R.layout.item_profile_list);
    }


    @Override
    protected void convert(@NonNull BaseViewHolder holder, ProfileActionListBean bean) {
        if (!TextUtils.isEmpty(bean.getIconUrl())) {
            GlideUtils.loadImage(getContext(), bean.getIconUrl(),holder.getView(R.id.data_item_icon));
        }
        holder.setText(R.id.txt_data_item_name, bean.getTitle());
        holder.setText(R.id.txt_data_item_status, bean.getStatusText());
        ((TextView) holder.getView(R.id.txt_data_item_status)).setTextColor(bean.getStatus() == 0 ? getContext().getResources().getColor(R.color.color_FF5D00) : getContext().getResources().getColor(R.color.color_black_four));

        //Done的情况下是否能点击还能实现
        if (bean.isEnableToClick()) {
            holder.getView(R.id.txt_data_item_status_arrow).setSelected(true);
        } else {
            holder.getView(R.id.txt_data_item_status_arrow).setSelected(false);
        }

        holder.setVisible(R.id.data_item_line, holder.getAdapterPosition() != getData().size() - 1);

    }
}
